home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / ice / cpp / tests / classmac.C next >
Encoding:
C/C++ Source or Header  |  1991-09-04  |  1.6 KB  |  46 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. // test file for the class, MACRO, and Template defmacros
  13. //
  14.  
  15. #pragma defmacro MACRO "macro" delimiter=} recursive
  16. #pragma defmacro class "class"
  17. #pragma defmacro classmac "classmac" delimiter=)
  18.  
  19. // tell the class macro to call the generate_slot_accessors macro inside
  20. // the class definition.  There will be a call to the slot_accessor macro
  21. // in the body arg to generate_slot_accessors for each slot in the class.
  22. classmac (generate_slot_accessors, inside, slots=slot_accessor)
  23.  
  24. // Invoked from the class macro
  25. MACRO generate_slot_accessors (class_name, base_class, BODY: methods) {
  26.  methods }
  27.  
  28. // expanded within my_generate_methods
  29. MACRO slot_accessor (type, name, value) {
  30.   const type& get_##name() { return name }
  31. }
  32.  
  33. class foo: virtual public Generic {
  34.  private:
  35.   int* data;                // Pointer to allocated storage
  36.   char *a, *b, c;            // Three miscellaneous variables
  37.   int size;                // Size of foo object
  38.   void grow (int new_size);        // Private function to grow foo
  39.  public:
  40.   foo (int);                // Constructor with size
  41.   ~foo (){};                // Destructor 
  42.   int& operator[] (int);        // Operator[] overload for Type
  43.   Boolean find (const int&);        // Find element in foo
  44.   // ..
  45. };
  46.